using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using WindowsFormsApplication1;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private string portname = "Not Initialized";
        private string baudrate = "Not Initialized";
        private string parity = "Not Initialized";
        private string stopbits = "Not Initialized";
        private string databits = "Not Initialized";
        private string handshaking = "Not Initialized";

        // Instantiate the PortSettings class
        PortSettings p = new PortSettings();

        public Form1()
        {
            InitializeComponent();
        }

        private void clearSettings()
        {
            portname = "";
            baudrate = "";
            databits = "";
            stopbits = "";
            parity = "";
            handshaking = "";
        }

        private void buttonTest_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("Dialog result = " + p.ShowDialog());

            if (p.ShowDialog() == DialogResult.Cancel)
            {
                // clear out settings
                clearLabels();
            }
            else
            {
                // set labels to Settings values
                setLabels();
            }
        }

        private void clearLabels()
        {
            labelPortName.Text = "PortName";
            labelBaudRate.Text = "BaudRate";
            labelParity.Text = "Parity";
            labelDataBits.Text = "DataBits";
            labelStopBits.Text = "StopBits";
            labelHandShaking.Text = "HandShaking";
        }

        private void setLabels()
        {
            labelPortName.Text = "PortName: " + p.selectedPort;
            labelBaudRate.Text = "BaudRate: " + p.selectedBaudrate.ToString();
            labelParity.Text = "Parity: " + p.selectedParity.ToString();
            labelDataBits.Text = "DataBits: " + p.selectedDataBits.ToString();
            labelStopBits.Text = "StopBits: " + p.selectedStopBits.ToString();
            labelHandShaking.Text = "HandShaking: " + p.selectedHandshaking.ToString();
        }
    }
}


